package com.redrose.videodemo.utils;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 *recycleview 水平间距控制
 */

public class SpaceItemDecoratio extends RecyclerView.ItemDecoration {
    private int space;

    public SpaceItemDecoratio(int space) {
        this.space = space;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        if(parent.getChildPosition(view) != 0)
            outRect.left = space;
    }
}
